from .basic import *
import logging

SECRET_KEY = '51)fj#mnm%-ctk6+$eah%5=rv(rsl(2k5ntivjgt&7f3=%a7j+'

WSGI_APPLICATION = 'wsgi_dev.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'ordersystem',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

# 其他配置
REDIS_HOST = "127.0.0.1"
REDIS_DB = 0
REDIS_PORT = "6379"

BROKER_URL = 'amqp://guest:guest@127.0.0.1:5672/long'  # 使用RabbitMQ作为消息代理
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/5'  # 把任务结果存在了Redis

BROKER = "120.36.152.254"
PORT = 21026
WAIT_TIME = 30

VERSION_PATH = "/Users/long/Desktop/shouhou/{}"
CONFIG_PATH = "/Users/long/Desktop/shouhou/configpath/{}/{}"

JSON_CONFIG_FILE_PATH = "/Users/long/Desktop/shouhou/configpath/{}/{}"
TEMP_FILE_DIR = "/Users/long/Desktop/shouhou/temp"
JSON_EXPLAIN_FILE_PATH = "/Users/long/Desktop/shouhou_docker/shouhou/json_explain.json"
INI_EXPLAIN_FILE_PATH = "/Users/long/Desktop/shouhou_docker/shouhou/ini_explain.json"

# 拼接的http
DOWNURL = "http://120.36.152.254:21011/api/file/down/"
UPLOADURL = "http://120.36.152.254:21011/api/file/upload/"
REMOVEFILE = "http://120.36.152.254:21011/api/file/remove_file?{}"
GET_MD5 = "http://120.36.152.254:21011/api/file/get_md5?{}&{}"
ANA_FILE = "http://120.36.152.254:21011/api/file/ana_file?{}"
IS_FILE = "http://120.36.152.254:21011/api/file/is_file?{}"
HISTORY_FRESH = "http://120.36.152.254:21011/api/history/fresh?{}"
AWAKE_GATEWAY = "http://120.36.152.254:21011/api/new_gateway/awake?{}"

LOGGING_DIR = "."
if not os.path.exists(LOGGING_DIR):
    os.mkdir(LOGGING_DIR)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '[%(levelname)s][%(asctime)s][%(filename)s][%(funcName)s][%(lineno)d] > %(message)s'
        },
        'simple': {
            'format': '[%(levelname)s]> %(message)s'
        },
    },
    'filters': {
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'file_handler': {
            'level': 'INFO',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'filename': '%s/django.log' % LOGGING_DIR,
            'formatter': 'standard'
        },  # 用于文件输出
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'formatter': 'standard'
        },
    },
    'loggers': {
        'mdjango': {
            'handlers': ['console', 'file_handler'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    }
}

LOGGER = logging.getLogger("mdjango")
